package com.liu.manager.mapper;

import com.liu.manager.entity.RolerAndPermission;
import com.liu.manager.entity.UserAndRoler;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RolerAndPermissionMapper {

    @Insert("insert info roler_permission(permission_id,roler_id,create_time) values(#{permissionId},#{rolerId},#{createTime})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    int insertPermissionAndRoler(RolerAndPermission userAndRoler);

    @Delete("delete from roler_permission where id=#{id}")
    int deletePermissionAndRoler(long id);

    @Select("select * from roler_permission where id=#{id}")
    RolerAndPermission findById(long id);

    @Select("select * from roler_permission where permission_id=#{permissionId}")
    List<RolerAndPermission> findByPermissionId(long permissionId);

    @Select("select * from roler_permission where roler_id=#{rolerId}")
    List<RolerAndPermission> findByRolerId(long rolerId);
}
